home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / new.toq < prev    next >
Text File  |  1995-03-23  |  3KB  |  113 lines

  1. Article 5408 of comp.sys.handhelds:
  2. Newsgroups: comp.sys.handhelds
  3. Path: en.ecn.purdue.edu!wscott
  4. From: wscott@en.ecn.purdue.edu (Wayne H Scott)
  5. Subject: Re: DEC2FRAC-II for the HP48SX
  6. Message-ID: <1991Mar30.191031.26274@en.ecn.purdue.edu>
  7. Organization: Purdue University Engineering Computer Network
  8. References: <12222
  9. Date: Sat, 30 Mar 91 19:10:31 GMT
  10.  
  11. In article <27f2c9cd:1772.4comp.sys.handhelds;1
  12. >Wayne Scott asks for DEC2FRAC to parse equations like ->Q does.
  13. >
  14. >No problem.  I'm on it...
  15. >
  16. >-- Joe Horn --
  17.  
  18. DO\->Q  Version 1.1
  19.  
  20.  
  21. Sorry I've already done it...
  22.  
  23. This program handles:
  24.     real numbers
  25.     complex numbers
  26.     equations
  27.     TAGGED objects
  28.     lists
  29.     and any combination of the above
  30.  
  31. { .25 '.5*X-.75' (.25, -.333) }
  32. 10
  33. DO\->Q
  34. { '1/4' '1/2*X-3/4' '1/4-1/3*i' }
  35.  
  36.  
  37. I now have this programs assigned to my old \->Q key.
  38. Many thanks to:
  39.     Joseph Korn for writing the DEC2FRAC program
  40. and    Jan Brittenson for showing me how to handle equations.  (I never 
  41.     knew OBJ\-> would do that) and for the SYSEVALS  in DO\->Q.
  42.  
  43. [ sorry typed in by hand }
  44. DO\->Q
  45. Checksum: # 603Ch
  46. Size:    424
  47.  
  48. \<< \-> A D
  49. \<< A TYPE \-> T \<<
  50.   CASE T 0 ==
  51.     THEN A D D2F END
  52.     T 9 == THEN A OBJ\-> \-> n oper \<<
  53.     1 n START D DO\->Q n ROLL NEXT
  54.     oper 
  55.     n 1 + # 18CEAh SYSEVAL        @ n+1 as system binary
  56.     # 546Dh SYSEVAL            @ join as algebraic
  57.     \>>
  58.     END
  59.     T 1 == THEN A RE D DO\->Q A IM D DO\->Q i * + END
  60.     T 5 == THEN A OBJ\-> \-> n \<< 1 n 
  61.     START D DO\->Q n ROLL NEXT
  62.     n \->LIST \>>
  63.     END
  64.     T 12 == THEN
  65.     A OBJ\-> SWAP D DO\->Q SWAP \->TAG END
  66.     A
  67.   END
  68. \>> \>> \>>
  69.  
  70.     
  71. D2F is the same program posted eariler with the following changes.
  72.  
  73. D2F
  74. Checksum: # 2667h
  75. Size: 339
  76. %%HP:T(3);
  77. \<< DUP2 
  78.   IF 1 > SWAP FP AND 
  79.   THEN SWAP EVAL \-> c f    @ added EVAL so it can handle '2/4'
  80.     \<< 0 1 f 
  81.       WHILE OVER c < OVER AND 
  82.       REPEAT INV DUP FP 4 ROLLD IP OVER * ROT + ROT 
  83.       END DROP DUP2 c 
  84.       IF DUP2 > 
  85.       THEN - OVER / CEIL * - 
  86.       ELSE 3 DROPN 
  87.       END DUP2 1 2 
  88.       START DUP f * 0 RND SWAP / f - ABS SWAP 
  89.       NEXT 
  90.       IF > 
  91.       THEN SWAP 
  92.       END DROP DUP f * 0 RND  
  93.     \>> 
  94. IF OVER 0 < THEN NEG SWAP NEG ELSE SWAP END    @ so -.25 -> -(1/4) not 1/-4
  95.     IF DUP ABS 1 > 
  96.     THEN # 5603Eh SYSEVAL 
  97.     ELSE DROP 
  98.     END 
  99.   ELSE DROP 
  100.   END 
  101. \>>
  102.  
  103. Joe --  Is there a better way to handle negitive fractions?
  104.  
  105.  
  106. -- 
  107. _________________________________________________________________________
  108. Wayne Scott             |  INTERNET: wscott@ecn.purdue.edu
  109. Electrical Engineering  |  BITNET:   wscott%ecn.purdue.edu@purccvm
  110. Purdue University       |  UUCP:     {purdue, pur-ee}!ecn.purdue.edu!wscott
  111.  
  112.  
  113.